package com.unswift.window.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.unswift.constant.ButtonConstant;
import com.unswift.utils.ThreadUtils;
import com.unswift.window.dialog.QuickDialog;

public class DialogButtonAction implements ActionListener{

	private QuickDialog dialog;
	
	public DialogButtonAction(QuickDialog dialog) {
		this.dialog=dialog;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		ThreadUtils.execute(new Runnable() {
			@Override
			public void run() {
				String action=e.getActionCommand();
				if(action.equals(ButtonConstant.ACTION_DIALOG_OPENING)){
					dialog.opening();
				}else if(action.equals(ButtonConstant.ACTION_DIALOG_CONFIRM)){
					dialog.confirm();
				}else if(action.equals(ButtonConstant.ACTION_DIALOG_CLOSE)){
					dialog.close();
				}else if(action.equals(ButtonConstant.ACTION_DIALOG_STOP)){
					dialog.stop();
				}else if(action.equals(ButtonConstant.ACTION_DIALOG_SEARCH)){
					dialog.search();
				}else if(action.equals(ButtonConstant.ACTION_DIALOG_REPLACE)){
					dialog.replace();
				}
			}
		});
	}
}
